package com.yuanqi.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;

/**
 * 库存事务流水
 * @TableName inventory_txn
 */
@TableName(value ="inventory_txn")
@Data
public class InventoryTxn implements Serializable {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 库存事务编码（系统生成）
     */
    private String txnCode;

    /**
     * 仓库ID
     */
    private Long warehouseId;

    /**
     * 库位ID
     */
    private Long locationId;

    /**
     * SKU ID
     */
    private Long skuId;

    /**
     * 批次号
     */
    private String batchNo;

    /**
     * 数量（入为正，出为负）
     */
    private BigDecimal txnQty;

    /**
     * 数量（入为正，出为负）
     */
    private BigDecimal qty;

    /**
     * 移动单价（用于移动加权）
     */
    private BigDecimal unitCost;

    /**
     * 事务类型：PO_IN/SO_OUT/ADJ/TRANSFER等
     */
    private String txnType;

    /**
     * 来源单据表名
     */
    private String referenceTable;

    /**
     * 来源单据主键
     */
    private Long referenceId;

    /**
     * 来源单据编号
     */
    private String referenceNo;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建时间
     */
    private Date createdAt;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        InventoryTxn other = (InventoryTxn) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getTxnCode() == null ? other.getTxnCode() == null : this.getTxnCode().equals(other.getTxnCode()))
            && (this.getWarehouseId() == null ? other.getWarehouseId() == null : this.getWarehouseId().equals(other.getWarehouseId()))
            && (this.getLocationId() == null ? other.getLocationId() == null : this.getLocationId().equals(other.getLocationId()))
            && (this.getSkuId() == null ? other.getSkuId() == null : this.getSkuId().equals(other.getSkuId()))
            && (this.getBatchNo() == null ? other.getBatchNo() == null : this.getBatchNo().equals(other.getBatchNo()))
            && (this.getQty() == null ? other.getQty() == null : this.getQty().equals(other.getQty()))
            && (this.getUnitCost() == null ? other.getUnitCost() == null : this.getUnitCost().equals(other.getUnitCost()))
            && (this.getTxnType() == null ? other.getTxnType() == null : this.getTxnType().equals(other.getTxnType()))
            && (this.getReferenceTable() == null ? other.getReferenceTable() == null : this.getReferenceTable().equals(other.getReferenceTable()))
            && (this.getReferenceId() == null ? other.getReferenceId() == null : this.getReferenceId().equals(other.getReferenceId()))
            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getTxnCode() == null) ? 0 : getTxnCode().hashCode());
        result = prime * result + ((getWarehouseId() == null) ? 0 : getWarehouseId().hashCode());
        result = prime * result + ((getLocationId() == null) ? 0 : getLocationId().hashCode());
        result = prime * result + ((getSkuId() == null) ? 0 : getSkuId().hashCode());
        result = prime * result + ((getBatchNo() == null) ? 0 : getBatchNo().hashCode());
        result = prime * result + ((getQty() == null) ? 0 : getQty().hashCode());
        result = prime * result + ((getUnitCost() == null) ? 0 : getUnitCost().hashCode());
        result = prime * result + ((getTxnType() == null) ? 0 : getTxnType().hashCode());
        result = prime * result + ((getReferenceTable() == null) ? 0 : getReferenceTable().hashCode());
        result = prime * result + ((getReferenceId() == null) ? 0 : getReferenceId().hashCode());
        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", txnCode=").append(txnCode);
        sb.append(", warehouseId=").append(warehouseId);
        sb.append(", locationId=").append(locationId);
        sb.append(", skuId=").append(skuId);
        sb.append(", batchNo=").append(batchNo);
        sb.append(", qty=").append(qty);
        sb.append(", unitCost=").append(unitCost);
        sb.append(", txnType=").append(txnType);
        sb.append(", referenceTable=").append(referenceTable);
        sb.append(", referenceId=").append(referenceId);
        sb.append(", remark=").append(remark);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}